﻿function Maiks:SlashCommands(input,arg1)
    if strlower(string.sub(input,1,3)) == "rbg" then 
        Maiks:RBGslash(input)
    elseif strlower(string.sub(input,1,7)) == "goodies" then 
        Maiks:Goodiesslash(input)    
    elseif strlower(string.sub(input,1,5)) == "forum" then
        Maiks:Forumslash(input)
    elseif strlower(string.sub(input,1,2)) == "gr" then 
        Maiks:GRslash(input)
    else 
        _,_,_,_,_,RBGreason,_ = GetAddOnInfo("Maiks-RBG")
        _,_,_,_,_,Goodiesreason,_ = GetAddOnInfo("Maiks-Goodies")
        _,_,_,_,_,Forumreason,_ = GetAddOnInfo("Maiks-Forum")
        _,_,_,_,_,GRreason,_ = GetAddOnInfo("Maiks-GR")
        if RBGreason == nil then
            if IsAddOnLoaded("Maiks-RBG") then
                print("Maiks: RBG loaded.")
            else
                print("Maiks: RBG not loaded.\n  Use '/maiks rbg' for options.")
            end
        elseif RBGreason == "MISSING" then
            print("Maiks: RBG not installed.")
        elseif RBGreason == "DEP_MISSING" then
            print("Maiks: RBG is missing a dependency.")
        end
        if Goodiesreason == nil then
            if IsAddOnLoaded("Maiks-Goodies") then
                print("Maiks: Goodies Enabled.\n  Use '/maiks goodies' for options.")
            else
                print("Maiks: Disabled.\n  Use '/maiks goodies' for options.")
            end
        elseif Goodiesreason == "MISSING" then
            print("Maiks: Goodies not installed.")
        elseif Goodiesreason == "DEP_MISSING" then
            print("Maiks: Goodies is missing a dependency.")
        end
        if Forumreason == nil then
            if IsAddOnLoaded("Maiks-Forum") then
                print("Maiks: Forum Enabled.\n  Use '/maiks forum' for options.")
            else
                print("Maiks: Forum.\n  Use '/maiks forum' for options.")
            end
        elseif Forumreason == "MISSING" then
            print("Maiks: Forum not installed.")
        elseif Forumreason == "DEP_MISSING" then
            print("Maiks: Forum is missing a dependency.")
        end
        if GRreason == nil then
            if IsAddOnLoaded("Maiks-GR") then
                print("Maiks: GR loaded.")
            else
                print("Maiks: GR not loaded.\n  Use '/maiks gr' for options.")
            end
        elseif GRreason == "MISSING" then
            print("Maiks: GR not installed.")
        elseif GRreason == "DEP_MISSING" then
            print("Maiks: GR is missing a dependency.")
        end
    end
end

function Maiks:RBGslash(input)
    if IsAddOnLoaded("Maiks-RBG") then
        if strlower(string.sub(input,5,8)) == "show" then
            Maiks_RBG_title_frame:Show()  
        elseif strlower(string.sub(input,5,8)) == "hide" then
            Maiks_RBG_title_frame:Hide()
        else
            print("Maiks: RBG is loaded.\nAvailable commands are:\n  /maiks rbg show\n  /maiks rbg hide")
        end
    elseif strlower(string.sub(input,5,8)) == "load" then 
        LoadAddOn("Maiks-RBG")
    else
        print("Maiks: RBG is not loaded.\nAvailable commands are:\n  /maiks rbg load")
    end
end

function Maiks:Goodiesslash(input) 
    local _,_,_,enabled,_,_,_ = GetAddOnInfo("Maiks-Goodies")
    if enabled then  
        if strlower(string.sub(input,9,15)) == "disable" then
            DisableAddOn("Maiks-Goodies")
            ReloadUI()
        else
            print("Maiks: Goodies Enabled.\nAvailable commands are:\n  /maiks goodies disable")
        end
    else  
        if strlower(string.sub(input,9,14)) == "enable" then
            EnableAddOn("Maiks-Goodies")
            ReloadUI()
        else
            print("Maiks: Goodies Disabled.\nAvailable commands are:\n  /maiks goodies enable")
        end
    end
end

function Maiks:Forumslash(input) 
    local _,_,_,enabled,_,_,_ = GetAddOnInfo("Maiks-Forum")
    if enabled then  
        if strlower(string.sub(input,7,13)) == "disable" then
            DisableAddOn("Maiks-Forum")
            ReloadUI()
        elseif strlower(string.sub(input,7,10)) == "show" then
            LibStub("AceConfigDialog-3.0"):Open("Maiks_Forum_table")
        elseif strlower(string.sub(input,7,10)) == "hide" then
            LibStub("AceConfigDialog-3.0"):Close("Maiks_Forum_table")
        else
            print("Maiks: Goodies Enabled.\nAvailable commands are:\n  /maiks goodies disable\n  /maiks goodies show\n  /maiks goodies hide")
        end
    else  
        if strlower(string.sub(input,7,12)) == "enable" then
            EnableAddOn("Maiks-Forum")
            ReloadUI()
        else
            print("Maiks: Goodies Disabled.\nAvailable commands are:\n  /maiks goodies enable")
        end
    end
end

function Maiks:GRslash(input)
    if IsAddOnLoaded("Maiks-GR") then
        if strlower(string.sub(input,4,16)) == "whisper start" then
            if Maiks_GR_Start == true then 
                print("Maiks: GR whisper has already started.")
            else
                Maiks_GR_Start = true
                print("Maiks: GR whisper has started.")
            end
        elseif strlower(string.sub(input,4,15)) == "whisper stop" then
            if Maiks_GR_Start == false then 
                print("Maiks: GR whisper has already stopped or has never started.")
            else
                Maiks_GR_Start = false  
                print("Maiks: GR whisper has stopped.")
            end
        elseif strlower(string.sub(input,4,13)) == "reset list" then
            Maiks_GRdb.NameList = {}
            print("Maiks: GR list has reset")
        elseif strlower(string.sub(input,4,16)) == "channel start" then
            if Maiks_GR_Channel == true then 
                print("Maiks: GR channel has already started.")
            else
                Maiks_GR_Channel = true
                print("Maiks: GR channel has started.")
            end
        elseif strlower(string.sub(input,4,15)) == "channel stop" then
            if Maiks_GR_Channel == false then 
                print("Maiks: GR channel has already stopped or has never started.")
            else
                Maiks_GR_Channel = false  
                print("Maiks: GR channel has stopped.")
            end
        else
            print("Maiks: GR is loaded.\nAvailable commands are:\n  /maiks gr start\n  /maiks gr stop\n  /maiks gr reset list")
        end
    elseif strlower(string.sub(input,4,7)) == "load" then 
        LoadAddOn("Maiks-GR")
    else
        print("Maiks: GR is not loaded.\nAvailable commands are:\n  /maiks gr load")
    end
end

    